package zhanyuduilie

type MyStack struct {
	inQueue  []int
	outQueue []int
}

func ConstructorLQueue() MyStack {
	return MyStack{}
}

func (this *MyStack) Push(x int) {
	this.inQueue = append(this.inQueue, x)
}

func (this *MyStack) Pop() int {
	for len(this.inQueue) > 0 {
		this.outQueue = append(this.outQueue, this.inQueue[0])
		this.inQueue = this.inQueue[1:]
	}
	x := this.outQueue[len(this.outQueue)-1]
	this.outQueue = this.outQueue[:len(this.outQueue)-1]
	return x
}

func (this *MyStack) Top() int {
	for len(this.inQueue) > 0 {
		this.outQueue = append(this.outQueue, this.inQueue[0])
		this.inQueue = this.inQueue[1:]
	}
	return this.outQueue[len(this.outQueue)-1]
}

func (this *MyStack) Empty() bool {
	return len(this.outQueue) == 0 && len(this.inQueue) == 0
}
